﻿using System.Linq;

namespace Framework.Sql
{
    public class CountSqlBuilder : SqlBuilderBase
    {
        public CountSqlBuilder(string connectionString, string tableName) : base(connectionString, tableName) { }

        public int Count()
        {
            var sql = string.Format("select count(*) from {0}", TableName);
            return (int) new SqlExecutor(ConnectionString).Exec(sql, dr => dr[0]).First();
        }
    }
}